<template>
	<view class="newsDetail">	
		<web-view :src="src" @message="handleMessage"></web-view>
	</view>
</template>

<script>
var dateUtils = require('../../common/util.js').dateUtils;
var util = require('../../common/util.js');
export default {
    data() {
        return {
            src: '',
            share_Poup: false,
            bottom: 'bottom',
            authTime: 0,
            authStatus: 'init',
            id: 0,
            login: false
        };
    },
    onLoad(option) {
		uni.showLoading({
				title: '加载中'
		});
        this.id = option.id;
        this.login = '' != util.getUserToken();
        console.log(this.login);
        if (this.login) {
            this.getUserInfo();
        } else {
            this.src =
                '/hybrid/html/projectDetail.html?id=' +
                this.id +
                '&login=' +
                this.login +
                '&authTime=' +
                this.authTime +
                '&authStatus=' +
                this.authStatus;
            console.log(this.src);
        }
    },
    methods: {
        hidePopup() {
            this.share_Poup = false;
        },
        handleMessage(evt) {
            console.log('接收到的消息：' + JSON.stringify(evt.detail.data));
        },
        getUserInfo() {
            util.ajax(
                'userDetail',
                {
                    token: util.getUserToken()
                },
                data => {
                    let json = data.data;
                    console.log(json);
                    if (json.status) {
                        this.authTime = json.data.authTime;
                        this.authStatus = json.data.authStatus.value;
                        this.src =
                            '/hybrid/html/projectDetail.html?id=' +
                            this.id +
                            '&login=' +
                            this.login +
                            '&authTime=' +
                            this.authTime +
                            '&authStatus=' +
                            this.authStatus;
                        console.log(this.src);
                    } else {
                        uni.showToast({
                            title: json.message,
                            icon: 'none',
                            duration: 1000
                        });
                    }
                },
                (data, code) => {
                    // console.log(data);
                    uni.showToast({
                        title: JSON.stringify(data.message),
                        icon: 'none',
                        duration: 1000
                    });
                }
            );
        }
    }
};
</script>

<style lang="less">
@import '../../common/icon.css';
page {
    background: white;
}
</style>
